<template>
    <div>
      <h1>
        新增付款单
      </h1>
      <el-form :inline="true" ref="form" :model="form" label-width="100px">
        <el-form-item label="收房合同号">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-button @click="houseClosing" type="warning" round>收房合同查询</el-button>
        <el-form-item label="房产信息">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <br>
        <el-form-item label="业主姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="业主手机号">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <br>
        <el-form-item label="选择账期">
          <el-select v-model="form.region" placeholder="--请选择--">
          </el-select>
        </el-form-item>
        <br>

        <el-form-item label="新增款项">
          <el-button type="warning" @click="addDomain">新增域名</el-button>
          <el-form-item
            v-for="(domain, index) in dynamicValidateForm.domains"
            :label="'费用类型' + index"
            :key="domain.key"
            :prop="'domains.' + index + '.value'"
          >
            <el-input v-model="domain.value"></el-input><el-button @click.prevent="removeDomain(domain)">删除</el-button>
          </el-form-item>
        </el-form-item>
        <br>

        <el-form-item label="是否付款" prop="resource">
          <el-radio-group v-model="dynamicValidateForm.resource">
            <el-radio label="已经付款">
              <template slot-scope="scope">
                <span>
                  <input></input>
                </span>
              </template>
            </el-radio>
            <el-radio onchange="" label="还未付款"></el-radio>
          </el-radio-group>
        </el-form-item>

        <br>

        <el-form-item label="备注" prop="desc">
          <el-input type="textarea" v-model="dynamicValidateForm.desc"></el-input>
        </el-form-item>
        <br>
        <el-form-item>
          <el-button>清空</el-button>
          <el-button type="warning" @click="onSubmit">保存</el-button>
          (此按钮只能点击一次)
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
  export default {
    data() {
      return {
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        dynamicValidateForm: {
          domains: [{
            value: ''
          }],
          email: ''
        }
      }
    },
    methods: {
      houseClosing(){

      },
      onSubmit() {
        console.log('submit!');
      },
      removeDomain(item) {
        var index = this.dynamicValidateForm.domains.indexOf(item)
        if (index !== -1) {
          this.dynamicValidateForm.domains.splice(index, 1);
        }
      },
      addDomain() {
        this.dynamicValidateForm.domains.push({
          value: '',
          key: Date.now()
        });
      }
    }
  }
</script>

<style scoped>

</style>
